<template>
  <div
    class="blog-header"
    :style="`background-image: url(${props.articleInfo.article_cover})`"
  >
    <div class="blog-header-content">
      <h1>{{ props.articleInfo.article_title }}</h1>
      <div class="blog-info">
        <div class="infos">
          <el-icon color="#05b5fa"><UserFilled /></el-icon>
          {{ props.articleInfo.authorName }}
        </div>
        <div class="infos">
          <el-icon color="#05b5fa"><Calendar /></el-icon>于
          {{ props.articleInfo.updateDate }} 更新
        </div>
        <div class="infos">
          <el-icon color="#05b5fa"><View /></el-icon> 阅读量:
          {{ props.articleInfo.view_times }}
        </div>
      </div>
      <div class="blog-info">
        <div>
          <span>分类:</span>
          <span class="classify">{{ props.articleInfo.categoryName }}</span>
        </div>
        <div>
          <span>标签:</span>
          <span v-for="x in props.articleInfo.tagNameList" class="classify">
            {{ x }}
          </span>
        </div>
        <div v-if="getUserInfo?.id === props.articleInfo.userId" class="edit-blog">
          <span @click="editArticle"
            ><el-icon color="#05b5fa"><Edit /></el-icon>&nbsp;&nbsp;编辑</span
          >
        </div>
      </div>
    </div>
    <div class="header-overlay"></div>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from "vue-router";
import { user } from "@/store";
const {getUserInfo} = user()
const router = useRouter();
const props = defineProps({
  articleInfo: {
    type: Object,
    default: {},
  },
});

const editArticle = () => {
  router.push({
    path: "/blogEdit",
    query: { articleId: props.articleInfo.id },
  });
};
</script>
<style lang="scss" scoped>
.blog-header {
  // background: linear-gradient(to right, #33ccff 0%, #62e979 50%, #ff99cc 100%);
  background-size: cover;
  background-position: center;
  background-color: rgb(36, 33, 33);
  text-align: center;
  @include flex();
  position: relative;
  .header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); // 设置半透明黑色覆盖层
    z-index: 0;
  }
  .blog-header-content {
    position: relative;
    z-index: 1;
    color: #ffffff;
    .blog-info {
      font-weight: 500;
      color: #ffffff;
      @include flex();
      flex-wrap: wrap;
      .infos {
        @include flex();
        i {
          cursor: pointer;
          margin-right: 5px;
        }
      }
    }
    h1 {
      font-size: 2rem;
      font-weight: bold;
      padding: 5px 0;
    }
    div {
      padding: 5px;
      span {
        margin-right: 20px;
      }
      .classify {
        padding: 2px 3px;
        cursor: pointer;
        // color:#29e918;
        // color:#05b5fa;
        box-shadow: 0 0 5px #05b5fa;
        border-radius: 5px;
        background-color: #05b5fa;
        cursor: pointer;
      }
    }
    .edit-blog {
      cursor: pointer;
      span {
        @include flex();
      }
    }
    .edit-blog:hover {
      color: #05b5fa;
    }
  }
}
@media screen and (min-width: 768px) {
  .blog-header {
    height: 300px;
  }
  .blog-info {
    font-size: 1rem;
  }
}
@media screen and (max-width: 768px) {
  .blog-header {
    height: 12rem;
  }
  .blog-info {
    font-size: 0.8rem;
  }
}
</style>
